import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Type } from '@angular/core';
import { CmpAPcComponent } from './pc/cmp.pc';
import { CmpDefaultComponent } from './default/cmp.default';
import { Platform } from '../env';
// import { provideComponents } from '../component.provide';


export function provideComponents() {
    console.log('provideComponents: evaluated');
    console.log(Platform);
    return function (constructor: Function) {
        debugger;
        if (Reflect.hasMetadata('annotations', constructor)) {
            console.log(Reflect.getMetadata('annotations', constructor));
            const ngDecs = Reflect.getMetadata('annotations', constructor);

            ngDecs.forEach(ngDec => {
                ngDec.declarations = ngDec.declarations.filter(c => {
                    return c.name.toUpperCase().indexOf(Platform.toUpperCase()) !== -1;
                });
                console.log(ngDec.declarations);

                ngDec.exports = ngDec.exports.filter(c => {
                    return c.name.toUpperCase().indexOf(Platform.toUpperCase()) !== -1;
                });
                console.log(ngDec.exports);
            });
            console.log(ngDecs);
        }
        console.log('provideComponents: called');
        console.log(constructor);
    };
}

@provideComponents()
@NgModule({
    declarations: [
        CmpAPcComponent, CmpDefaultComponent
    ],
    imports: [

    ],
    providers: [],
    exports: [CmpAPcComponent, CmpDefaultComponent]
})
export class CmpAModule { }
